package edu.ynmd.database.action;

import edu.ynmd.database.dao.StudentDao;
import edu.ynmd.database.model.StudentmdEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.sql.Timestamp;

@Controller
public class PublicAction {
    @Autowired
    private StudentDao studentDao;

    @GetMapping("testDao")
    @ResponseBody
    public boolean testDao () throws Exception{

        //添加数据到数据库
       /* StudentmdEntity student=new StudentmdEntity();
        student.setStunum("201621447225");
        student.setName("毛毛");
        student.setSex("F");
        student.setBirthday(new Timestamp(System.currentTimeMillis()));
        student.setNativeplace("玉溪");
        studentDao.save(student);
        */

        //修改数据
       /* StudentmdEntity student=new StudentmdEntity();
        student.setStunum("201621447235");
        student.setName("绒绒");
        student.setSex("F");
        student.setNativeplace("玉溪");
        student.setStudentid("e09bd55e-8f87-4204-a9f8-fec3d2f8673f");
        studentDao.save(student);
        */

       //查询单个数据
        /*  StudentmdEntity s=studentDao.findOne("50dc58f5-24b6-457a-986f-2bbe2df0d0f4");
        s.setBirthday(new Timestamp(System.currentTimeMillis()));
        s.setNativeplace("昆明");
        studentDao.save(s);
        */

        //删除数据
        StudentmdEntity s=new StudentmdEntity();
        s.setStudentid("50dc58f5-24b6-457a-986f-2bbe2df0d0f4");
        studentDao.delete(s);

        return true;
    }
}
